﻿using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Serilog;
using Serilog.Formatting.Json;
using SystemServices;

namespace ConsoleApp1
{
    internal class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello, World!");

            ServiceCollection services = new ServiceCollection();
            services.AddLogging(logBuilder =>
            {
                //logBuilder.SetMinimumLevel(LogLevel.Trace);
                //logBuilder.AddConsole();
                //logBuilder.AddNLog();

                Log.Logger = new LoggerConfiguration()
                    .MinimumLevel.Debug()
                    .Enrich.FromLogContext()
                    //.WriteTo.Console(new JsonFormatter())
                    .WriteTo.Console()
                    .CreateLogger();

                logBuilder.AddSerilog();

            });
            services.AddScoped<TestController>();
            services.AddScoped<SystemServiceController>();

            using (var sp = services.BuildServiceProvider())
            {
                var test = sp.GetRequiredService<TestController>();
                var systemService = sp.GetRequiredService<SystemServiceController>();

                test.Test();
                systemService.Test();

                //int i = 0;
                //while(i < 1000)
                //{
                //    test.Test();
                //    systemService.Test();
                //    i++;
                //}
            }
        }
    }
}
